package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import form.ConnectionDB;

import model.Thuthuat;

public class ThuthuatDAO {

	public static boolean insert(Thuthuat thuthuat)
			throws ClassNotFoundException, SQLException {
		Connection connection = ConnectionDB.getConnection();
		String sql = "insert into thuthuat(hinh,title,title_khongdau,ngayviet,thoigianviet,noidung) values (?,?,?,?,?,?)";
		PreparedStatement ps = connection.prepareStatement(sql);
		ps.setString(1, thuthuat.getHinh());
		ps.setString(2, thuthuat.getTitle());
		ps.setString(3, thuthuat.getTitle_khongdau());
		ps.setDate(4, thuthuat.getNgayviet());
		ps.setTime(5, thuthuat.getThoigianviet());
		ps.setString(6, thuthuat.getNoidung());

		
		int change = 0;
		change = ps.executeUpdate();
		connection.close();
		if (change > 0) {
			return true;
		} else {

			return false;
		}
	}

	public static void main(String[] args) {
		

	}

}
